home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / ARITEST.ZIP / DEMOS / VBDEMO / FORM1.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-12-22  |  3.7 KB  |  131 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "DAO Speed Test VB"
  5.    ClientHeight    =   3030
  6.    ClientLeft      =   1770
  7.    ClientTop       =   3075
  8.    ClientWidth     =   6825
  9.    Height          =   3435
  10.    Left            =   1710
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3030
  15.    ScaleWidth      =   6825
  16.    Top             =   2730
  17.    Width           =   6945
  18.    Begin VB.TextBox txtNumRecs 
  19.       Alignment       =   1  'Right Justify
  20.       Height          =   495
  21.       Left            =   3960
  22.       MaxLength       =   6
  23.       TabIndex        =   3
  24.       Text            =   "0"
  25.       Top             =   2280
  26.       Width           =   1575
  27.    End
  28.    Begin VB.CommandButton btnStart 
  29.       Caption         =   "Start"
  30.       Height          =   375
  31.       Left            =   120
  32.       TabIndex        =   1
  33.       Top             =   840
  34.       Width           =   1095
  35.    End
  36.    Begin VB.ListBox lstTimeResults 
  37.       Height          =   2010
  38.       ItemData        =   "Form1.frx":0000
  39.       Left            =   1320
  40.       List            =   "Form1.frx":0002
  41.       TabIndex        =   0
  42.       Top             =   120
  43.       Width           =   5415
  44.    End
  45.    Begin VB.Label Label1 
  46.       Caption         =   "Enter The Number Of Records To Use In This Test:"
  47.       Height          =   255
  48.       Left            =   120
  49.       TabIndex        =   2
  50.       Top             =   2400
  51.       Width           =   3735
  52.    End
  53. Attribute VB_Name = "Form1"
  54. Attribute VB_Creatable = False
  55. Attribute VB_Exposed = False
  56. Private Sub btnStart_Click()
  57.   If Val(txtNumRecs) < 1000 Then
  58.     txtNumRecs.Text = "1000"
  59.   End If
  60.   If Val(txtNumRecs) > 100000 Then
  61.     txtNumRecs.Text = "100000"
  62.   End If
  63.   btnStart.Enabled = False
  64.   'set up variables
  65.   Dim MyWs As Workspace
  66.   Dim MyDb As Database
  67.   Dim MyRs As Recordset
  68.   Dim Tbl1 As TableDef
  69.   Dim Fld1 As Field
  70.   Dim Fld2 As Field
  71.   Dim sT1, eT1 As Long
  72.   Dim s, e As Long
  73.   ' start time t1
  74.   sT1 = Timer
  75.   Set MyWs = DBEngine.Workspaces(0)
  76.   'create database
  77.   ' start time t2
  78.   s = Timer
  79.   Set MyDb = MyWs.CreateDatabase("SpeedVB.mdb", dbLangGeneral, dbVersion30)
  80.   Set Tbl1 = MyDb.CreateTableDef("Table1")
  81.   Set Fld1 = Tbl1.CreateField("IntField", dbLong)
  82.   Fld1.Attributes = dbAutoIncrField
  83.   Set Fld2 = Tbl1.CreateField("TextField", dbText)
  84.   Fld2.Size = 30
  85.   Tbl1.Fields.Append Fld1
  86.   Tbl1.Fields.Append Fld2
  87.   MyDb.TableDefs.Append Tbl1
  88.   e = Timer
  89.   ' end time t2
  90.   lstTimeResults.AddItem "Created SpeedVB.MDB - " + Str(e - s)
  91.   'fill data
  92.   ' start time t3
  93.   s = Timer
  94.   Set MyRs = MyDb.OpenRecordset("Table1", dbOpenTable, 0)
  95.   For i = 1 To Val(txtNumRecs)
  96.     MyRs.AddNew
  97.     MyRs![TextField] = "Entry #" + Str(i)
  98.     MyRs.Update
  99.   Next i
  100.   MyRs.Close
  101.   e = Timer
  102.   ' end time t3
  103.   lstTimeResults.AddItem "Filled SpeedVB.MDB With Data - " + Str(e - s)
  104.   'forward naviagation of data
  105.   ' start time t4
  106.   s = Timer
  107.   Set MyRs = MyDb.OpenRecordset("Table1", dbOpenTable, 0)
  108.   Do Until MyRs.EOF
  109.     MyRs.MoveNext
  110.   Loop
  111.   MyRs.Close
  112.   e = Timer
  113.   ' end time t4
  114.   lstTimeResults.AddItem "Navigated Forward Through SpeedVB.MDB - " + Str(e - s)
  115.   'backward naviagation of data
  116.   ' start time t5
  117.   s = Timer
  118.   Set MyRs = MyDb.OpenRecordset("Table1", dbOpenTable, 0)
  119.   MyRs.MoveLast
  120.     MyRs.MovePrevious
  121.   Loop While Not MyRs.BOF
  122.   MyRs.Close
  123.   e = Timer
  124.   ' end time t5
  125.   lstTimeResults.AddItem "Navigated Backward Through SpeedVB.MDB - " + Str(e - s)
  126.   btnStart.Enabled = True
  127.   eT1 = Timer
  128.   'end time t1
  129.   lstTimeResults.AddItem "Total Time: " + Str(eT1 - sT1)
  130. End Sub
  131.